/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.admin
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-4-28
 * @time 下午3:31:18
 */
package com.ssh.web.admin;

import java.sql.Timestamp;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.model.pdata.VVisitorMPData;
import com.ssh.ser.admin.VVisitorManageSerI;

/**
 * @author jack
 * @desc 外来车辆管理Action
 */
public class QVehicleVisitorAction extends ActionSupport {

	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	private Timestamp inTime;
	private Timestamp vcarInTime;
	private String vehicleId;
	private VVisitorManageSerI vehVisitorManageI;
	private VVisitorMPData vehVisitorMPData;
	private List<VVisitorMPData> vehVisitorMPDataList;
	private String visitorId;

	/*
	 * (non-Javadoc)
	 *
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return viewVVisitorByCondtion();
	}

	/**
	 * @return the inTime
	 */
	public Timestamp getInTime() {
		return inTime;
	}

	/**
	 * @return the vcarInTime
	 */
	public Timestamp getVcarInTime() {
		return vcarInTime;
	}

	/**
	 * @return the vehicleId
	 */
	public String getVehicleId() {
		return vehicleId;
	}

	/**
	 * @return the vehVisitorManageI
	 */
	public VVisitorManageSerI getVehVisitorManageI() {
		return vehVisitorManageI;
	}

	/**
	 * @return the vehVisitorMPData
	 */
	public VVisitorMPData getVehVisitorMPData() {
		return vehVisitorMPData;
	}

	/**
	 * @return the vehVisitorMPDataList
	 */
	public List<VVisitorMPData> getVehVisitorMPDataList() {
		return vehVisitorMPDataList;
	}

	/**
	 * @return the visitorId
	 */
	public String getVisitorId() {
		return visitorId;
	}

	/**
	 * @param inTime
	 *            the inTime to set
	 */
	public void setInTime(Timestamp inTime) {
		this.inTime = inTime;
	}

	/**
	 * @param vcarInTime
	 *            the vcarInTime to set
	 */
	public void setVcarInTime(Timestamp vcarInTime) {
		this.vcarInTime = vcarInTime;
	}

	/**
	 * @param vehicleId
	 *            the vehicleId to set
	 */
	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
	}

	/**
	 * @param vehVisitorManageI
	 *            the vehVisitorManageI to set
	 */
	public void setVehVisitorManageI(VVisitorManageSerI vehVisitorManageI) {
		this.vehVisitorManageI = vehVisitorManageI;
	}

	/**
	 * @param vehVisitorMPData
	 *            the vehVisitorMPData to set
	 */
	public void setVehVisitorMPData(VVisitorMPData vehVisitorMPData) {
		this.vehVisitorMPData = vehVisitorMPData;
	}

	/**
	 * @param vehVisitorMPDataList
	 *            the vehVisitorMPDataList to set
	 */
	public void setVehVisitorMPDataList(
			List<VVisitorMPData> vehVisitorMPDataList) {
		this.vehVisitorMPDataList = vehVisitorMPDataList;
	}

	/**
	 * @param visitorId
	 *            the visitorId to set
	 */
	public void setVisitorId(String visitorId) {
		this.visitorId = visitorId;
	}

	public String viewOneVehVisitorAllInfo() {
		try {
			vehVisitorMPData = vehVisitorManageI.viewOneVVisitor(vehicleId,
					visitorId, inTime);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "viewOneVVAllInfo";
	}

	public String viewVVisitorByCondtion() {
		try {
			if (vehicleId.equals("")
					&& (vcarInTime == null || vcarInTime.equals(""))) {
				vehVisitorMPDataList = vehVisitorManageI.viewAllVVisitor();
				return "viewAll";
			} else if (!vehicleId.equals("")
					&& (vcarInTime == null || vcarInTime.equals("")))
				vehVisitorMPDataList = vehVisitorManageI
						.viewVVisitorByVehicleId(vehicleId);
			else if (vehicleId.equals("") && !vcarInTime.equals(""))
				vehVisitorMPDataList = vehVisitorManageI
						.viewVVisitorByInTime(vcarInTime);
			else if (!vehicleId.equals("") && !vcarInTime.equals(""))
				vehVisitorMPDataList.add(vehVisitorManageI.viewOneVVisitor(
						vehicleId, vcarInTime));
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "viewByCondition";
	}

}
